package com.interesting.client.application;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.telephony.TelephonyManager;

import com.interesting.base.lazylist.ImageLoader;
import com.interesting.base.utils.SQLiteUtil;
import com.interesting.client.bean.User;

public class AppHolder {

	private static AppHolder instance;
	public  SQLiteUtil dbAdapter;
	private AppHolder() {
		// navList = new ArrayList<Map<String, String>>();
	}

	public static AppHolder getInsatnce() {
		if (instance == null)
			instance = new AppHolder();
		return instance;
	}

	public ImageLoader imageLoader;// 全局 ImageLoader
	public String appID;// 程序标识
	public String cityID;// 城市地区标识
	public String currentCity;// 当前城市
	public String currApkUrl;// 当前apk下载地址

	public User user;// 用户信息

	public boolean isNetWorkConnection = false;

	/** 手机信息获取 */
	// 获得手机型号
	private String phonetype = "";

	public String getPhoneType() {
		try {
			if (phonetype.equals("")) {
				phonetype = android.os.Build.MODEL;
			}
		} catch (Exception e) {
			phonetype = "无法获取型号";
		}
		return phonetype;
	}

	// IMEI
	private String imei = "";

	public String getImei(Context context) {
		try {
			if (imei.equals("")) {
				TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
				imei = tm.getDeviceId();
			}
		} catch (Exception e) {

		}

		return imei;
	}

	// IMSI
	private String imsi = "";

	public String getImsi(Context context) {
		try {
			if (imsi.equals("")) {
				imsi = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getSubscriberId();
			}
		} catch (Exception e) {
			imsi = "";
			e.printStackTrace();
		}
		return imsi;
	}

	// 电话
	private String phone = "";

	public String getPhone(Context context) {
		try {
			if (phone.equals("")) {
				phone = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
			}
		} catch (Exception e) {
			phone = "";
			e.printStackTrace();
		}

		return phone;
	}

	// 版本
	private String version = "";

	public String getVersion(Context context) {
		if (version.equals("")) {
			try {
				PackageManager packageManager = context.getPackageManager();
				PackageInfo packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
				version = packInfo.versionName;
			} catch (Exception e) {

			}
		}
		return version;
	}

	public String mByOrSupply = "11";// 00 buy; 11 supply
}
